<?php defined('SYSPATH') OR die('No direct access allowed.');

class Category_Controller extends Template_Controller {
	const ALLOW_PRODUCTION = FALSE;
	public $template = 'layouts/template_admin';

	public function index(){
		$this->template->content = new View('category/create');
		$this->template->content->captcha = Captcha::factory();
		$this->template->content->categorys=ORM::factory("category")->find_all();
		$this->template->title = 'สร้างกลุ่มสินค้า';
	}
	public function testmenu(){
		$this->template->content = new View('category/testmenu');
		$this->template->title = 'สร้างกลุ่มสินค้า';
	}
	
	public function create(){
		$this->template->content = new View('category/create');
		$this->template->content->captcha = Captcha::factory();
		$this->template->content->categorys=ORM::factory("category")->find_all();
		$this->template->title = 'สร้างกลุ่มสินค้า';
	}
	public function insert(){
		$category = new Category_Model();
		$category->name=$this->input->post("name");
		$category->save();
		url::redirect("category/category/listResult");
	}
	public function listResult(){
		$this->template->content = new View('category/listResult');
		$this->template->content->categories=ORM::factory("category")->find_all();
		$this->template->title = 'แสดงรายการ  กลุ่มสินค้า ทั้งหมด';
	}
}
?>
